import { createSSRApp } from "vue"
import App from "./App.vue"
import pinia from "./stores"
import { i18n } from "./locale"
import Progress from "./components/progress/index.vue"
import Paging from './components/paging/index.vue'
import LoadPage from './components/load-page/index.vue'
import Button from './components/button/index.vue'
import Font from './components/font/index.vue'
import Checkbox from './components/checkbox/index.vue'
import Input from './components/input/index.vue'
import Numberbox from './components/numberbox/index.vue'
import Popup from './components/popup/index.vue'
import ConfirmPopup from './components/confirm-popup/index.vue'
import ChooseImage from "./components/choose-image/index.vue"
import Tab from './components/tab/index.vue'
import TabItem from './components/tab/tab-item/index.vue'
import Select from './components/select/index.vue'
import Option from './components/select/option/index.vue'
import '@/styles/index.scss'

export function createApp() {
  const app = createSSRApp(App)
  app.use(pinia)
  app.use(i18n)
  
  const components = [
    Progress, Paging, LoadPage, Button, Font, Checkbox,
    Input, Numberbox, Popup, ConfirmPopup, ChooseImage,
    Tab, TabItem, Select, Option
  ]
  components.forEach(com => app.component(com.name!, com))

  uni.on = uni.$on
  uni.once = uni.$once
  uni.emit = uni.$emit
  uni.off = uni.$off

  return {
    app,
  }
}
